﻿$(function(){//延迟加载
	var dvbelong='';
	var ipresId='';
	var url='showdvmodel?devresId=0&dvfirmId=0';
	
	showdvmodel(url);
	
	function showdvmodel(url){
		$('#modellist').datagrid({
			width:'auto',
			height:'auto',
			toolbar:'#tb2',
			url:url,
			async:true,
			method:'get',
			pagination:true,
			rownumbers:true,
			fit:true,
			columns:
				[[
				{"field":"devresname",
				"title":"设备类型",
				"width":"100px"
				},
				{
				"field":"modelname",
				"title":"设备型号",
				"width":"100px"
				},
				{
				"field":"dvfirm",
				"title":"设备厂商",
				"width":"100px"
				},
				{
				"field":"portnum",
				"title":"端口数",
				"width":"70px"
				},
				{
				"field":"boardnum",
				"title":"每板端口数",
				"width":"70px"
				},
				{
				"field":"ylport",
				"title":"预留端口数",
				"width":"70px"
				},
				{
				"field":"zhukong",
				"title":"主控板",
				"width":"100px"
				},
				{
				"field":"beizhu",
				"title":"备注",
				"width":"150px"
				}
				]],
				onClickRow:function(index,row){
					
				},
				onLoadSuccess:function(data){
					var pager = $('#modellist').datagrid('getPager');	// get the pager of datagrid
					pager.pagination({
						buttons:[{
							iconCls:'icon-add',
							handler:function(){
								parent.addTab('添加设备型号','toaddmodel');
							}
						},{
							iconCls:'icon-edit',
							handler:function(){
								alert('edit');
							}
						}]
					});
					
				}
		});
	}
	
	$('#dvbelong').combobox({
		onChange:function(){
			url='showdvmodel?devresId='+newValue+'&dvfirmId='+$('#dvfirm').combobox('getValue');
			showdvmodel(url);
		}
	});	
	$('#dvfirm').combobox({
		onChange:function(newValue,oldValue){
			url='showdvmodel?devresId='+$('#dvbelong').combobox('getValue')+'&dvfirmId='+newValue;
			showdvmodel(url);
		}
	});
});